#!/bin/bash

# 环境设置
# 1.修改hive-site.xml文件
sed -i '21r ./conf/hive-site.txt' /home/hadoop/apache-hive-2.3.5-bin/conf/hive-site.xml
# 2.拷贝hcatalog lib到flume lib目录
cp ${HIVE_HOME}/hcatalog/share/hcatalog/* ${FLUME_HOME}/lib/
# 3.修改mysql链接权限
mysql -u root -proot << EOF
update mysql.user set Host = '%' where Host = '::1' and User = 'root';
flush privileges;
EOF
sleep 3s
# 4.修改mysql配置文件并重启
sudo sed -i 's/^bind-address.*/bind-address = 0.0.0.0/' /etc/mysql/my.cnf
sudo sed -i '/character_set_server/d; /collation-server/d' /etc/mysql/my.cnf
sudo sed -i '/\[mysqld\]/a character_set_server=utf8\ncollation-server=utf8_unicode_ci' /etc/mysql/my.cnf
sleep 3s
sudo service mysql restart